package com.heima.bos.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.heima.bos.dao.DaoInter;
import com.heima.bos.dao.FunctionDaoInter;
import com.heima.bos.domain.Function;
import com.heima.bos.domain.User;
@Service
@Transactional
public class FunctionService extends BaseService<Function>{
	@Resource
	private FunctionDaoInter functionDao;
	@Override
	public DaoInter<Function> getDao() {
		return functionDao;
	}
	/**
	 * 根据用户加载菜单
	 * @param user
	 * @return
	 */
	public List<Function> findMenu(User user) {
		String username = user.getUsername();
		List<Function> functions = null;
		if(username.equals("wangwei")){
			functions = functionDao.findAllMenu();
		}else{
			functions = functionDao.findMenuByUserId(user.getId());
		}
		return functions;
	}

}
